home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / flowel.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  52 lines

  1. /*****************************************************************************
  2.  
  3.     FlowEL()
  4.  
  5.     This function exits the current loop.  It is called when a loop
  6. command (<) is executed with a numeric argument less than or equal to zero,
  7. when a semi-colon command is executed with a numeric argument greater than
  8. zero,  when a search command within a loop fails,  or when an F> command is
  9. executed.
  10.  
  11. *****************************************************************************/
  12.  
  13. #include "zport.h"        /* define portability identifiers */
  14. #include "tecoc.h"        /* define general identifiers */
  15. #include "defext.h"        /* define external global variables */
  16. #include "deferr.h"        /* define identifiers for error messages */
  17.  
  18. DEFAULT FlowEL()        /* flow to end of loop */
  19. {
  20.     WORD    TmpNst;        /* temporary loop nest count */
  21.  
  22.     DBGFEN(3,"FlowEL",NULL);
  23.  
  24.     TmpNst = 1;
  25.     do {
  26.         if (CBfPtr == CStEnd) {        /* if end of command string */
  27.             ErrUTC();        /* unterminated command */
  28.             DBGFEX(3,DbgFNm,"FAILURE");
  29.             return FAILURE;
  30.         }
  31.         ++CBfPtr;            /* move to next command */
  32.         if (*CBfPtr == '<') {        /* if loop start character */
  33.             ++TmpNst;        /* increment nesting count */
  34.         } else if (*CBfPtr == '>') {    /* else if loop end char */
  35.             --TmpNst;        /* decrement nesting count */
  36.         } else {
  37.             if (SkpCmd() == FAILURE) {
  38.                 DBGFEX(3,DbgFNm,"FAILURE");
  39.                 return FAILURE;
  40.             }
  41.         }
  42.     } while (TmpNst > 0);
  43.  
  44.     if (TraceM) {                /* if tracing is on */
  45.         EchoIt(*CBfPtr);        /* echo the character */
  46.     }
  47.     --LStTop;                /* pop loop stack */
  48.  
  49.     DBGFEX(3,DbgFNm,"FlowEL");
  50.     return SUCCESS;
  51. }
  52.